package org.example.pcbcircuitboard.controller;

import org.example.pcbcircuitboard.constants.StatusCode;
import org.example.pcbcircuitboard.constants.StatusData;
import org.example.pcbcircuitboard.pojo.CenterBottomPojo;
import org.example.pcbcircuitboard.pojo.LeftCenterPojo;
import org.example.pcbcircuitboard.pojo.ProductsPojo;
import org.example.pcbcircuitboard.service.VisualizationDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 可视化数据接口
 */
@RestController
@RequestMapping("/vis-data")
public class VisualizationDataController {
    @Autowired
    private VisualizationDataService visualizationDataService;
    /**
     * 左中数据接口
     * @param productsPojo 产品名称
     * @return 左中数据
     */
    @PostMapping("/left-center-data")
    public StatusData<Integer, List<LeftCenterPojo>> leftCenterData(@RequestBody ProductsPojo productsPojo) {
        String productName = productsPojo.getName();
        List<LeftCenterPojo> leftCenterPojos = visualizationDataService.getLeftCenterData(productName);
        return new StatusData<>(StatusCode.SUCCESS, leftCenterPojos);
    }
    /**
     * 种下数据接口
     */
    @PostMapping("/center-bottom-data")
    public StatusData<Integer,List<CenterBottomPojo>> centerBottomData() {
        List<CenterBottomPojo> centerBottomPojos = visualizationDataService.getCenterBottomData();
        return new StatusData<>(StatusCode.SUCCESS, centerBottomPojos);
    }
}
